// (Population projection) Rewrite Programming Exercise 1.11 to prompt the user 
// to enter the number of years and displays the population after the number of years. 
// Use the hint in Programming Exercise 1.11 for this program. The population 
// should be cast into an integer.
import java.util.Scanner;

public class test211 {
    public static void main(String[] args) {
        Scanner input = new Scanner(System.in);
        
        // 提示用户输入年数
        System.out.print("Enter the number of years: ");
        int years = input.nextInt();
        
        // 当前人口（根据Exercise 1.11）
        int currentPopulation = 312032486;
        
        // 一年中的秒数
        int secondsInYear = 365 * 24 * 60 * 60;
        
        // 计算每年的人口变化
        double birthsPerYear = secondsInYear / 7.0;
        double deathsPerYear = secondsInYear / 13.0;
        double immigrantsPerYear = secondsInYear / 45.0;
        
        // 计算年人口净增长
        double annualIncrease = birthsPerYear - deathsPerYear + immigrantsPerYear;
        
        // 计算未来人口
        int futurePopulation = currentPopulation + (int)(years * annualIncrease);
        
        // 显示结果
        System.out.println("The population in " + years + " years is " + futurePopulation);
        
        // 关闭Scanner
        input.close();
    }
}
